home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / M / LSP⁄C.cpt / compare.p < prev    next >
Text File  |  1989-01-06  |  16KB  |  760 lines

  1. PROGRAM LSP_SHELL;
  2.  
  3. {$I-}
  4.  
  5.     USES
  6.         GLOBALS, INIT, SANE;
  7.  
  8.  
  9.     PROCEDURE cfillptr (aP: Ptr; blockSize: Longint; fillChar: CHAR);
  10.     EXTERNAL;
  11.  
  12.     PROCEDURE crfillptr (aP: Ptr; blockSize: Longint; fillChar: CHAR);
  13.     EXTERNAL;
  14.  
  15.     PROCEDURE pfillptr (aP: Ptr; blockSize: Longint; fillChar: CHAR);
  16.         VAR
  17.             limitPtr: Ptr;
  18.     BEGIN
  19.         limitPtr := Ptr(ORD4(aP) + blockSize);
  20.         WHILE ORD4(aP) < ORD4(limitPtr) DO
  21.             BEGIN
  22.                 aP^ := SignedByte(fillChar);
  23.                 aP := Ptr(Succ(ORD4(aP)));
  24.             END;
  25.     END;
  26.  
  27.     PROCEDURE CalcPerformance;
  28.         VAR
  29.             divisor: Extended;
  30.     BEGIN
  31.         CASE perfIndex OF
  32.             TO_C_FUNCTION: 
  33.                 divisor := Extended(cTime / 1.0);
  34.             TO_CR_FUNCTION: 
  35.                 divisor := Extended(crTime / 1.0);
  36.             TO_P_FUNCTION: 
  37.                 divisor := Extended(pTime / 1.0);
  38.             OTHERWISE
  39.                 ;
  40.         END;
  41.         IF divisor > 0.0 THEN
  42.             BEGIN
  43.                 cPerf := cTime / divisor;
  44.                 crPerf := crTime / divisor;
  45.                 pPerf := pTime / divisor;
  46.             END;
  47.     END;
  48.  
  49.     PROCEDURE doRectFrame (r: Rect);
  50.     BEGIN
  51.         InsetRect(r, -1, -1);
  52.         FrameRect(r);
  53.     END;
  54.  
  55.     PROCEDURE DrawMainWindow;
  56.         VAR
  57.             aStr: Str255;
  58.             hiliteRect: Rect;
  59.             dForm: DecForm;
  60.             dStr: DecStr;
  61.     BEGIN
  62.         doRectFrame(ptrSizeDst);
  63.         doRectFrame(loopSizeDst);
  64.         doRectFrame(cTimeDst);
  65.         doRectFrame(crTimeDst);
  66.         doRectFrame(pTimeDst);
  67.         doRectFrame(cPerfDst);
  68.         doRectFrame(crPerfDst);
  69.         doRectFrame(pPerfDst);
  70.  
  71.         CASE perfIndex OF
  72.             TO_C_FUNCTION: 
  73.                 hiliteRect := cPerfDst;
  74.             TO_CR_FUNCTION: 
  75.                 hiliteRect := crPerfDst;
  76.             TO_P_FUNCTION: 
  77.                 hiliteRect := pPerfDst;
  78.             OTHERWISE
  79.                 ;
  80.         END;
  81.  
  82.         InsetRect(hiliteRect, -2, -2);
  83.         FrameRect(hiliteRect);
  84.  
  85.         hiliteRect := theWindow^.portRect;
  86.         WITH do_it^^.contrlRect DO
  87.             BEGIN
  88.                 MoveTo(hiliteRect.left, bottom + 4);
  89.                 LineTo(hiliteRect.right, bottom + 4);
  90.                 MoveTo(hiliteRect.left, bottom + 6);
  91.                 LineTo(hiliteRect.right, bottom + 6);
  92.             END;
  93.  
  94.         TextFace([bold]);
  95.  
  96.         aStr := 'Filling a block of';
  97.         MoveTo(ptrSizeDst.left - 4 - StringWidth(aStr), ptrSizeDst.bottom - 4);
  98.         DrawString(aStr);
  99.  
  100.         TextFace([]);
  101.  
  102.         NumToString(pSize, aStr);
  103.         TextBox(Ptr(ORD(@aStr[1])), length(aStr), ptrSizeDst, teJustCenter);
  104.  
  105.         TextFace([bold]);
  106.  
  107.         aStr := 'bytes';
  108.         MoveTo(ptrSizeDst.right + 4, ptrSizeDst.bottom - 4);
  109.         DrawString(aStr);
  110.  
  111.         TextFace([]);
  112.  
  113.         NumToString(Longint(numLoops), aStr);
  114.         TextBox(Ptr(ORD(@aStr[1])), length(aStr), loopSizeDst, teJustCenter);
  115.  
  116.         TextFace([bold]);
  117.  
  118.         aStr := 'times...';
  119.         MoveTo(loopSizeDst.right + 4, loopSizeDst.bottom - 4);
  120.         DrawString(aStr);
  121.  
  122.         aStr := 'C function';
  123.         MoveTo(cTimeDst.left - 4 - StringWidth(aStr), cTimeDst.bottom - 4);
  124.         DrawString(aStr);
  125.  
  126.         aStr := 'C function using registers';
  127.         MoveTo(crTimeDst.left - 4 - StringWidth(aStr), crTimeDst.bottom - 4);
  128.         DrawString(aStr);
  129.  
  130.         aStr := 'Pascal procedure';
  131.         MoveTo(pTimeDst.left - 4 - StringWidth(aStr), pTimeDst.bottom - 4);
  132.         DrawString(aStr);
  133.  
  134.         aStr := '1/60ths seconds';
  135.  
  136.         MoveTo(cTimeDst.left + (cTimeDst.right - cTimeDst.left - StringWidth(aStr)) DIV 2, cTimeDst.top - 8);
  137.         DrawString(aStr);
  138.  
  139.         aStr := 'Performance Index';
  140.  
  141.         MoveTo(cPerfDst.left + (cPerfDst.right - cPerfDst.left - StringWidth(aStr)) DIV 2, cPerfDst.top - 8);
  142.         DrawString(aStr);
  143.  
  144.         TextFace([]);
  145.  
  146.         NumToString(Longint(cTime), aStr);
  147.         TextBox(Ptr(ORD(@aStr[1])), length(aStr), cTimeDst, teJustCenter);
  148.  
  149.         NumToString(Longint(crTime), aStr);
  150.         TextBox(Ptr(ORD(@aStr[1])), length(aStr), crTimeDst, teJustCenter);
  151.  
  152.         NumToString(Longint(pTime), aStr);
  153.         TextBox(Ptr(ORD(@aStr[1])), length(aStr), pTimeDst, teJustCenter);
  154.  
  155.         dForm.style := FIXEDDECIMAL;
  156.         dForm.digits := 8;
  157.  
  158.         Num2Str(dForm, cPerf, dStr);
  159.         TextBox(Ptr(ORD(@dStr[1])), length(dStr), cPerfDst, teJustCenter);
  160.  
  161.         Num2Str(dForm, crPerf, dStr);
  162.         TextBox(Ptr(ORD(@dStr[1])), length(dStr), crPerfDst, teJustCenter);
  163.  
  164.         Num2Str(dForm, pPerf, dStr);
  165.         TextBox(Ptr(ORD(@dStr[1])), length(dStr), pPerfDst, teJustCenter);
  166.  
  167.  
  168.     END;
  169.  
  170.     PROCEDURE HandleUpdate (windToUpdate: WindowPtr);
  171.         VAR
  172.             currPort: GrafPtr;
  173.             theRect: Rect;
  174.             aStr: Str255;
  175.     BEGIN
  176.         GetPort(currPort);
  177.         SetPort(windToUpdate);
  178.  
  179.         IF windToUpdate = theWindow THEN
  180.             BEGIN
  181.                 BeginUpdate(windToUpdate);
  182.                 EraseRect(windToUpdate^.portRect);
  183.                 DrawControls(windToUpdate);
  184.                 DrawMainWindow;
  185.                 EndUpdate(windToUpdate);
  186.             END
  187.         ELSE
  188.             BEGIN
  189.                 BeginUpdate(windToUpdate);
  190.                 EraseRect(windToUpdate^.portRect);
  191.                 EndUpdate(windToUpdate);
  192.             END;
  193.         SetPort(currPort);
  194.     END;
  195.  
  196.     PROCEDURE DoTest;
  197.         VAR
  198.             index: Integer;
  199.             timer: Longint;
  200.             aPtr: Ptr;
  201.             oldPort: GrafPtr;
  202.     BEGIN
  203.         SetCursor(GetCursor(watchCursor)^^);
  204.  
  205.         aPtr := NIL;
  206.         aPtr := NewPtr(pSize);
  207.         IF aPtr <> NIL THEN
  208.             BEGIN
  209.                 GetPort(oldPort);
  210.                 SetPort(theWindow);
  211.  
  212.                 FillRect(cTimeDst, gray);
  213.                 FillRect(cPerfDst, gray);
  214.                 cPerf := 0.0;
  215.                 timer := TickCount;
  216.                 WHILE timer = TickCount DO
  217.                     ;
  218.                 timer := TickCount;
  219.                 FOR index := 1 TO numLoops DO
  220.                     cfillptr(aPtr, pSize, 'A');
  221.                 cTime := TickCount - timer;
  222.  
  223.                 InvalRect(cTimeDst);
  224.                 InvalRect(cPerfDst);
  225.                 HandleUpdate(theWindow);
  226.  
  227.                 FillRect(crTimeDst, gray);
  228.                 FillRect(crPerfDst, gray);
  229.                 crPerf := 0.0;
  230.                 timer := TickCount;
  231.                 WHILE timer = TickCount DO
  232.                     ;
  233.                 timer := TickCount;
  234.                 FOR index := 1 TO numLoops DO
  235.                     crfillptr(aPtr, pSize, 'B');
  236.                 crTime := TickCount - timer;
  237.  
  238.                 InvalRect(crPerfDst);
  239.                 InvalRect(crTimeDst);
  240.                 HandleUpdate(theWindow);
  241.  
  242.                 FillRect(pTimeDst, gray);
  243.                 FillRect(pPerfDst, gray);
  244.                 pPerf := 0.0;
  245.                 timer := TickCount;
  246.                 WHILE timer = TickCount DO
  247.                     ;
  248.                 timer := TickCount;
  249.                 FOR index := 1 TO numLoops DO
  250.                     pfillptr(aPtr, pSize, 'C');
  251.                 pTime := TickCount - timer;
  252.  
  253.                 InvalRect(pPerfDst);
  254.                 InvalRect(pTimeDst);
  255.                 HandleUpdate(theWindow);
  256.  
  257.                 CalcPerformance;
  258.  
  259.                 InvalRect(cPerfDst);
  260.                 InvalRect(crPerfDst);
  261.                 InvalRect(pPerfDst);
  262.  
  263.                 DisposPtr(aPtr);
  264.                 SetPort(oldPort);
  265.             END;
  266.  
  267.         InitCursor;
  268.     END;
  269.  
  270.     PROCEDURE Easy_Out;
  271.     BEGIN
  272.         ExitToShell;
  273.     END;
  274.  
  275.     PROCEDURE DoAbout;
  276.         VAR
  277.             AboutWindow: WindowPtr;
  278.             AWRect: Rect;
  279.             aStr: Str255;
  280.             tHandle: Handle;
  281.             goAway: ControlHandle;
  282.             aControl: ControlHandle;
  283.             lEvent: EventRecord;
  284.             part: Integer;
  285.             done: Boolean;
  286.     BEGIN
  287.         SetRect(AWRect, 0, 0, 400, 300);
  288.         AboutWindow := NewWindow(NIL, AWRect, 'About Pascal • C Demo', FALSE, 4, WindowPtr(-1), FALSE, 0);
  289.         SetPort(AboutWindow);
  290.         TextFont(3);
  291.         TextSize(9);
  292.         TextFace([]);
  293.         CenterWindow(AboutWindow, screenBits.bounds);
  294.  
  295.         AWRect := AboutWindow^.portRect;
  296.         WITH AWRect DO
  297.             BEGIN
  298.                 bottom := bottom - 20;
  299.                 top := bottom - 20;
  300.                 left := (right - left - 80) DIV 2;
  301.                 right := left + 80;
  302.             END;
  303.  
  304.         goAway := NewControl(AboutWindow, AWRect, 'OK', TRUE, 0, 0, 1, 0, 0);
  305.  
  306.         ShowWindow(AboutWindow);
  307.         DrawControls(AboutWindow);
  308.  
  309.         AWRect := AboutWindow^.portRect;
  310.         AWRect.bottom := goAway^^.contrlRect.top - 10;
  311.  
  312.         InsetRect(AWRect, 8, 8);
  313.         FrameRect(AWRect);
  314.         InsetRect(AWRect, 2, 2);
  315.         FrameRect(AWRect);
  316.         InsetRect(AWRect, 10, 10);
  317.  
  318.         tHandle := GetResource('TEXT', 1000);
  319.         HLock(tHandle);
  320.         TextBox(tHandle^, GetHandleSize(tHandle), AWRect, teJustLeft);
  321.         HUnlock(tHandle);
  322.         ReleaseResource(tHandle);
  323.  
  324.         done := FALSE;
  325.         REPEAT
  326.             IF GetNextEvent(mDownMask + mUpMask, lEvent) THEN
  327.                 BEGIN
  328.                     GlobalToLocal(levent.where);
  329.                     part := FindControl(levent.where, AboutWindow, aControl);
  330.                     IF aControl = goAway THEN
  331.                         BEGIN
  332.                             part := TrackControl(aControl, levent.where, NIL);
  333.                             IF part = inButton THEN
  334.                                 done := TRUE;
  335.                         END;
  336.                 END;
  337.         UNTIL done;
  338.  
  339.         FlushEvents(mDownMask, 0);
  340.  
  341.         HideWindow(AboutWindow);
  342.         DisposeWindow(AboutWindow);
  343.  
  344.     END;
  345.  
  346.     PROCEDURE DoAppleMenu (menuItem: Integer);
  347.         VAR
  348.             aStr: Str255;
  349.             ignoreRef: Integer;
  350.     BEGIN
  351.         CASE menuItem OF
  352.             ABOUTITEM: 
  353.                 DoAbout;
  354.             OTHERWISE
  355.                 BEGIN
  356.                     GetItem(appleMenu, menuItem, aStr);
  357.                     ignoreRef := OpenDeskAcc(aStr);
  358.                 END;
  359.         END;
  360.     END;
  361.  
  362.     PROCEDURE DoFileMenu (menuItem: Integer);
  363.     BEGIN
  364.         CASE menuItem OF
  365.             NEWITEM: 
  366.                 ;
  367.             OPENITEM: 
  368.                 ;
  369.             CLOSEITEM: 
  370.                 ;
  371.             SAVEITEM: 
  372.                 ;
  373.             SAVEASITEM: 
  374.                 ;
  375.             PAGESETUPITEM: 
  376.                 ;
  377.             PRINTITEM: 
  378.                 ;
  379.             QUITITEM: 
  380.                 userQuit := TRUE;
  381.             OTHERWISE
  382.                 ;
  383.         END;
  384.     END;
  385.  
  386.     PROCEDURE DoEditMenu (menuItem: Integer);
  387.     BEGIN
  388.         IF NOT SystemEdit(menuItem - 1) THEN
  389.             BEGIN
  390.                 CASE menuItem OF
  391.                     UNDOITEM: 
  392.                         ;
  393.                     CUTITEM: 
  394.                         ;
  395.                     COPYITEM: 
  396.                         ;
  397.                     PASTEITEM: 
  398.                         ;
  399.                     CLEARITEM: 
  400.                         ;
  401.                     OTHERWISE
  402.                         ;
  403.                 END;
  404.             END;
  405.     END;
  406.  
  407.     PROCEDURE DoLoopMenu (menuItem: Integer);
  408.         VAR
  409.             iStr: Str255;
  410.             newNum: Longint;
  411.             index: Integer;
  412.             limit: Integer;
  413.             oldPort: GrafPtr;
  414.     BEGIN
  415.         GetItem(loopMenu, menuItem, iStr);
  416.         StringToNum(iStr, newNum);
  417.         numLoops := Integer(newNum);
  418.  
  419.         limit := CountMItems(loopMenu);
  420.         FOR index := 1 TO limit DO
  421.             CheckItem(loopMenu, index, FALSE);
  422.         CheckItem(loopMenu, menuItem, TRUE);
  423.  
  424.         cTime := 0;
  425.         crTime := 0;
  426.         pTime := 0;
  427.  
  428.         GetPort(oldPort);
  429.         SetPort(theWindow);
  430.         InvalRect(loopSizeDst);
  431.         InvalRect(cTimeDst);
  432.         InvalRect(crTimeDst);
  433.         InvalRect(pTimeDst);
  434.         SetPort(oldPort);
  435.  
  436.         HandleUpdate(theWindow);
  437.     END;
  438.  
  439.     PROCEDURE DoPointerMenu (menuItem: Integer);
  440.         VAR
  441.             iStr: Str255;
  442.             spacePos: Integer;
  443.             index: Integer;
  444.             limit: Integer;
  445.             oldPort: GrafPtr;
  446.     BEGIN
  447.         limit := CountMItems(pointerMenu);
  448.         FOR index := 1 TO limit DO
  449.             CheckItem(pointerMenu, index, FALSE);
  450.         CheckItem(pointerMenu, menuItem, TRUE);
  451.         GetItem(pointerMenu, menuItem, iStr);
  452.         spacePos := Pos(' ', iStr);
  453.         delete(iStr, spacePos, length(iStr) - spacePos + 1);
  454.         StringToNum(iStr, pSize);
  455.  
  456.         cTime := 0;
  457.         crTime := 0;
  458.         pTime := 0;
  459.  
  460.         GetPort(oldPort);
  461.         SetPort(theWindow);
  462.         InvalRect(ptrSizeDst);
  463.         SetPort(oldPort);
  464.         HandleUpdate(theWindow);
  465.     END;
  466.  
  467.     PROCEDURE DoCompareMenu (menuItem: Integer);
  468.     BEGIN
  469.         CASE menuItem OF
  470.             4: 
  471.                 DoTest;
  472.             OTHERWISE
  473.                 ;
  474.         END;
  475.     END;
  476.  
  477.     PROCEDURE DoMenuDispatch (menuCode: Longint);
  478.         VAR
  479.             menuID, menuItem: Integer;
  480.     BEGIN
  481.         menuID := HiWrd(menuCode);
  482.         menuItem := LoWrd(menuCode);
  483.         CASE menuID OF
  484.             APPLEID: 
  485.                 DoAppleMenu(menuItem);
  486.             FILEID: 
  487.                 DoFileMenu(menuItem);
  488.             EDITID: 
  489.                 DoEditMenu(menuItem);
  490.             COMPAREID: 
  491.                 DoCompareMenu(menuItem);
  492.             POINTERID: 
  493.                 DoPointerMenu(menuItem);
  494.             LOOPID: 
  495.                 DoLoopMenu(menuItem);
  496.             OTHERWISE
  497.                 ;
  498.         END;
  499.         HiliteMenu(0);
  500.     END;
  501.  
  502.     PROCEDURE FixEditMenu (forWhom: context);
  503.     BEGIN
  504.         CASE forWhom OF
  505.             system: 
  506.                 BEGIN
  507.                     EnableItem(editMenu, UNDOITEM);
  508.                     EnableItem(editMenu, CUTITEM);
  509.                     EnableItem(editMenu, COPYITEM);
  510.                     EnableItem(editMenu, PASTEITEM);
  511.                     EnableItem(editMenu, CLEARITEM);
  512.                 END;
  513.             application: 
  514.                 BEGIN
  515.                     DisableItem(editMenu, UNDOITEM);
  516.                     DisableItem(editMenu, CUTITEM);
  517.                     DisableItem(editMenu, COPYITEM);
  518.                     DisableItem(editMenu, PASTEITEM);
  519.                     DisableItem(editMenu, CLEARITEM);
  520.                 END;
  521.             OTHERWISE
  522.                 ;
  523.         END;
  524.     END;
  525.  
  526.     PROCEDURE HandleMenus (clickPt: Point);
  527.         VAR
  528.             theMenuChoice: Longint;
  529.     BEGIN
  530.         theMenuChoice := MenuSelect(clickPt);
  531.         DoMenuDispatch(theMenuChoice);
  532.     END;
  533.  
  534.     PROCEDURE DoContent (inWindow: WindowPtr; mouseHit: Point);
  535.         VAR
  536.             part: Integer;
  537.             theControl: ControlHandle;
  538.             newPerformance: Integer;
  539.             eRect: Rect;
  540.     BEGIN
  541.         IF inWindow <> FrontWindow THEN
  542.             SelectWindow(inWindow)
  543.         ELSE
  544.             BEGIN
  545.                 GlobalToLocal(mouseHit);
  546.  
  547.                 IF inWindow = theWindow THEN
  548.                     BEGIN
  549.  
  550.                         part := FindControl(mouseHit, inWindow, theControl);
  551.                         IF (part = inButton) & (theControl = do_it) THEN
  552.                             BEGIN
  553.                                 part := TrackControl(theControl, mouseHit, NIL);
  554.                                 IF part = inButton THEN
  555.                                     doTest;
  556.                             END
  557.                         ELSE
  558.                             BEGIN
  559.                                 newPerformance := 0;
  560.  
  561.                                 IF PtInRect(mouseHit, cPerfDst) OR PtInRect(mouseHit, cTimeDst) THEN
  562.                                     newPerformance := TO_C_FUNCTION;
  563.                                 IF PtInRect(mouseHit, crPerfDst) OR PtInRect(mouseHit, crTimeDst) THEN
  564.                                     newPerformance := TO_CR_FUNCTION;
  565.                                 IF PtInRect(mouseHit, pPerfDst) OR PtInRect(mouseHit, pTimeDst) THEN
  566.                                     newPerformance := TO_P_FUNCTION;
  567.  
  568.                                 IF newPerformance > 0 THEN
  569.                                     BEGIN
  570.                                         perfIndex := newPerformance;
  571.                                         eRect := cPerfDst;
  572.                                         InsetRect(eRect, -2, -2);
  573.                                         InvalRect(eRect);
  574.                                         eRect := crPerfDst;
  575.                                         InsetRect(eRect, -2, -2);
  576.                                         InvalRect(eRect);
  577.                                         eRect := pPerfDst;
  578.                                         InsetRect(eRect, -2, -2);
  579.                                         InvalRect(eRect);
  580.  
  581.                                         CalcPerformance;
  582.                                     END;
  583.                             END;
  584.                     END;
  585.  
  586.             END;
  587.     END;
  588.  
  589.     PROCEDURE DoDrag (whichWindow: WindowPtr; startPt: Point);
  590.     BEGIN
  591.         SetPort(whichWindow);
  592.         DragWindow(whichWindow, startPt, screenBits.bounds);
  593.     END;
  594.  
  595.     PROCEDURE DoGrow (whichWindow: WindowPtr; startPt: Point);
  596.         VAR
  597.             limitRect: Rect;
  598.             newSize: Longint;
  599.     BEGIN
  600.         IF whichWindow <> FrontWindow THEN
  601.             SelectWindow(whichWindow)
  602.         ELSE
  603.             BEGIN
  604.                 SetRect(limitRect, 160, 80, 640, 480);
  605.                 newSize := GrowWindow(whichWindow, startPt, limitRect);
  606.                 IF newSize <> 0 THEN
  607.                     BEGIN
  608.                         InvalRect(whichWindow^.portRect);
  609.                         SizeWindow(whichWindow, LoWrd(newSize), HiWrd(newSize), TRUE);
  610.                     END;
  611.             END;
  612.     END;
  613.  
  614.     PROCEDURE DoGoAway (whichWindow: WindowPtr; whereHit: Point);
  615.     BEGIN
  616.         IF TrackGoAway(whichWindow, whereHit) THEN
  617.             IF whichWindow = theWindow THEN
  618.                 userQuit := TRUE
  619.             ELSE
  620.                 HideWindow(whichWindow);
  621.     END;
  622.  
  623.     PROCEDURE DoZoom (zWindow: WindowPtr; whichWay: Integer);
  624.     BEGIN
  625.         HideWindow(zWindow);
  626.         ZoomWindow(zWindow, whichWay, FALSE);
  627.         ShowWindow(zWindow);
  628.     END;
  629.  
  630.     PROCEDURE HandleMouseDown;
  631.         VAR
  632.             whichWindow: WindowPtr;
  633.             thePart: Integer;
  634.     BEGIN
  635.         thePart := FindWindow(theEvent.where, whichWindow);
  636.         CASE thePart OF
  637.             inSysWindow: 
  638.                 SystemClick(theEvent, whichWindow);
  639.             inDesk: 
  640.                 ;
  641.             inMenuBar: 
  642.                 HandleMenus(theEvent.where);
  643.             inContent: 
  644.                 DoContent(whichWindow, theEvent.where);
  645.             inDrag: 
  646.                 DoDrag(whichWindow, theEvent.where);
  647.             inGrow: 
  648.                 DoGrow(whichWindow, theEvent.where);
  649.             inGoAway: 
  650.                 DoGoAway(whichWindow, theEvent.where);
  651.             inZoomIn, inZoomOut: 
  652.                 DoZoom(whichWindow, thePart);
  653.             OTHERWISE
  654.                 ;
  655.         END;
  656.     END;
  657.  
  658.     PROCEDURE HandleKeyDown;
  659.         TYPE
  660.             LongToKey = RECORD
  661.                     CASE boolean OF
  662.                         TRUE: (
  663.                                 l: Longint
  664.                         );
  665.                         FALSE: (
  666.                                 chs: PACKED ARRAY[1..4] OF CHAR
  667.                         );
  668.                 END;
  669.         VAR
  670.             ch: CHAR;
  671.     BEGIN
  672.         ch := LongToKey(theEvent.message).chs[4];
  673.         IF BitAnd(theEvent.modifiers, cmdKey) = cmdKey THEN
  674.             DoMenuDispatch(MenuKey(ch))
  675.         ELSE
  676.             BEGIN
  677.             END;
  678.     END;
  679.  
  680.     PROCEDURE HandleActivate;
  681.         VAR
  682.             currPort: GrafPtr;
  683.             actWindow: WindowPtr;
  684.     BEGIN
  685.         GetPort(currPort);
  686.         actWindow := WindowPtr(theEvent.message);
  687.         SetPort(actWindow);
  688.  
  689.         IF actWindow = theWindow THEN
  690.             BEGIN
  691.                 IF BitAnd(theEvent.modifiers, activeFlag) = activeFlag THEN
  692.                     BEGIN
  693.                         FixEditMenu(application);
  694.                         IF BitAnd(theEvent.modifiers, CHANGEFLAG) = CHANGEFLAG THEN
  695.                             BEGIN
  696.                             END;
  697.                     END
  698.                 ELSE
  699.                     BEGIN
  700.                         FixEditMenu(system);
  701.                         IF BitAnd(theEvent.modifiers, CHANGEFLAG) = CHANGEFLAG THEN
  702.                             BEGIN
  703.                             END;
  704.                     END;
  705.             END;
  706.  
  707.     END;
  708.  
  709.     PROCEDURE CloseUpShop;
  710.     BEGIN
  711.         DeleteMenu(EDITID);
  712.         DisposeMenu(editMenu);
  713.         DeleteMenu(FILEID);
  714.         DisposeMenu(fileMenu);
  715.         DeleteMenu(APPLEID);
  716.         DisposeMenu(appleMenu);
  717.         DeleteMenu(LOOPID);
  718.         DisposeMenu(loopMenu);
  719.         DeleteMenu(COMPAREID);
  720.         DisposeMenu(compareMenu);
  721.  
  722.         DrawMenuBar;
  723.  
  724.         WHILE FrontWindow <> NIL DO
  725.             HideWindow(FrontWindow);
  726.     END;
  727.  
  728.     PROCEDURE HandleTheEvent;
  729.     BEGIN
  730.         CASE theEvent.what OF
  731.             mouseDown: 
  732.                 HandleMouseDown;
  733.             keyDown, autoKey: 
  734.                 HandleKeyDown;
  735.             updateEvt: 
  736.                 HandleUpdate(WindowPtr(theEvent.message));
  737.             activateEvt: 
  738.                 HandleActivate;
  739.             OTHERWISE
  740.                 ;
  741.         END;
  742.     END;
  743.  
  744. BEGIN
  745.     Init_Mac(@Easy_Out);
  746.     MakeMenus;
  747.     MakeWindow;
  748.     UnloadSeg(@Init_Mac);
  749.  
  750.     userQuit := FALSE;
  751.  
  752.     REPEAT
  753.         SystemTask;
  754.         IF GetNextEvent(everyEvent, theEvent) THEN
  755.             HandleTheEvent;
  756.     UNTIL userQuit;
  757.  
  758.     CloseUpShop;
  759.  
  760. END.